package com.ruoyi.common.enums;

public enum DrillEnum {

    NOT_STARTED(0, "未开始"),
    IN_PROGRESS(1, "进行中"),
    FINISHED(2, "已结束");

    private final int code;
    private final String description;

    DrillEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据 code 获取对应的枚举
    public static DrillEnum fromCode(int code) {
        for (DrillEnum status : DrillEnum.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    @Override
    public String toString() {
        return this.description;
    }
}
